<?php

class Core_Model_Global_Collection_Module extends Dcmp_Model_Collection_Strong {

    public function __construct() {
        parent::__construct();
        $this->setItemClass('global/module');
        $this->from('{t}global_module', 'a')->field('a.*');
    }

    public function joinArea(){
        return $this->innerJoin('{t}global_module_area', 'b', 'b.module_id', 'a.id');
    }

    public function filterBy($name, $arg) {
        switch ($name) {
            case 'id':
                return $this->addParameter('id', $arg)->eq('a.id', ':id:s');
            case 'areaid':
                return $this->addParameter('areaId', $arg)->eq('b.area_id', ':areaId:s');
        }
        return parent::filterBy($name, $arg);
    }
}

